package com.yanqu.road.server.cmd.rank;

import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.rank.RankMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author ：zfr
 * @date ：2021/9/15 18:43
 */
@Cmd(code = GameProtocol.S_CROSS_NOTIFY_UPLOAD_RANK_DATA, desc = "上传排行榜数据")
public class UploadRankDataCmd implements Command {
    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        if (RankMgr.uploadRankData()) {
            RankProto.CrossNotifyUploadRankDataRespMsg.Builder respMsg = RankProto.CrossNotifyUploadRankDataRespMsg.newBuilder();
            YanQuMessage message = YanQuMessageUtils.buildMessage(CrossProtocol.C_CROSS_RANK_UPLOAD_OVER_SYNC, respMsg);
            GamePlayerMgr.sendPacket(0, message);
        }
    }
}
